﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using TransFormer.BLL;

namespace TransFormer.Web
{
    public partial class Index : System.Web.UI.Page
    {
        private readonly BLL.Clients _bllClients = new  BLL.Clients();
        private readonly BLL.KeyWords _bllKey = new KeyWords();
        protected string Keywords { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            var model = _bllKey.GetModel(1);
            if (model != null)
            {
                HtmlMeta keywords = new HtmlMeta();
                keywords.Name = "keywords";
                keywords.Content = model.KeyContent;
                Page.Header.Controls.Add(keywords);
                HtmlMeta desc = new HtmlMeta();
                desc.Name = "description";
                desc.Content = model.PageDesc;
                Page.Header.Controls.Add(desc);
                Title = model.Title;
                
            }
        }

        protected void LiuYan(object sender, EventArgs e)
        {
            var rateText = ctl00_ContentPlaceholder_FlexibleContent_ctl07_rateThisPage_TextBoxMessage.Value;
            var emailText = ctl00_ContentPlaceholder_FlexibleContent_ctl07_rateThisPage_TextBoxFrom.Value;
            if (string.IsNullOrEmpty(emailText) || string.IsNullOrEmpty(rateText)) return;
            _bllClients.Add(new Model.Clients()
            {
                Date = DateTime.Now,
                Email = emailText,
                IsReaded = false,
                Message = rateText
            });
        }
    }
}